import { defineStore } from 'pinia'
import { getApiList } from '../api/index'
import type { RootObject, Children, ChinaAdd, ChinaTotal, localCityNCOVDataList } from './type'

export const useStore = defineStore('data',{
  state: () => {
    return {
      list: <RootObject>{},
      item:<Children[]>[],
      chinaAdd:<ChinaAdd>{},
      chinaTotal:<ChinaTotal>{},
      cityDetail:<localCityNCOVDataList[]>[],
    }
  },
  actions: {
    async getlist() {
      const result = await getApiList()
      this.list = result
      this.chinaAdd = this.list.diseaseh5Shelf.chinaAdd
      this.chinaTotal = this.list.diseaseh5Shelf.chinaTotal
      this.cityDetail = this.list.localCityNCOVDataList.slice(0,10)
    }
  }
})